package com.credithc.eagleeye.init;
import com.credithc.eagleeye.queue.EagleRedisQueueManager;
import com.credithc.eagleeye.queue.EagleTraceInfoQueueManager;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;
/**
 * 描 述: <br/>
 * 作 者: zhangjin<br/>
 * 创 建：2018年02月06日<br/>
 * 版 本：v1.0.0<br>
 * <p>
 * 历 史: (版本) 作者 时间 注释 <br/>
 */
@Slf4j
@Component
public class InitRunner implements ApplicationRunner, InitializingBean, DisposableBean {
    @Autowired
    private ApplicationContext applicationContext;
    @Autowired
    private EagleTraceInfoQueueManager traceInfoQueueManager;
    @Autowired
    private EagleRedisQueueManager redisQueueManager;
    @Override
    public void run(ApplicationArguments args) throws Exception {
        log.info("eagle-eye-transfer-boot init run starting...");

        log.info("eagle-eye-transfer-boot init run success...");
    }
    @Override
    public void afterPropertiesSet() throws Exception {
        traceInfoQueueManager.start();
        redisQueueManager.start();
    }

    @Override
    public void destroy() throws Exception {
        traceInfoQueueManager.stop();
        redisQueueManager.stop();
    }

}
